-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce TyErr
independent from TyInfer
#40887
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
ed0e5dd
to
0835f7c
Compare
|
src/libsyntax/parse/parser.rs
Outdated
@@ -4330,6 +4330,26 @@ impl<'a> Parser<'a> { | |||
|
|||
fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool) | |||
-> PResult<'a, (Vec<Arg> , bool)> { | |||
|
|||
/// Create a placeholder argument | |||
fn dummy_arg(span: Span) -> Arg { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: error reporting is a "cold" code for a reader trying to understand the main logic (syntax of fn arguments in this case), it often makes sense to factor it into a separate function (already done) and move it somewhere else, so it's invisible unless intentionally looked for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@petrochenkov done. |
TyPlaceholder
independent from TyInfer
TyErr
independent from TyInfer
Add a `TyErr` type to represent unknown types in places where parse errors have happened, while still able to build the AST. Initially only used to represent incorrectly written fn arguments and avoid "expected X parameters, found Y" errors when called with the appropriate amount of parameters. We cannot use `TyInfer` for this as `_` is not allowed as a valid argument type. Example output: ```rust error: expected one of `:` or `@`, found `,` --> file.rs:12:9 | 12 | fn bar(x, y: usize) {} | ^ error[E0061]: this function takes 2 parameters but 3 parameters were supplied --> file.rs:19:9 | 12 | fn bar(x, y) {} | --------------- defined here ... 19 | bar(1, 2, 3); | ^^^^^^^ expected 2 parameters ```
@bors r+ |
📌 Commit b83352e has been approved by |
☔ The latest upstream changes (presumably #41121) made this pull request unmergeable. Please resolve the merge conflicts. |
60b37ee
to
d01bc33
Compare
@bors r=petrochenkov |
📌 Commit 8c31412 has been approved by |
⌛ Testing commit 8c31412 with merge 566afe4... |
💔 Test failed - status-appveyor |
Introduce `TyErr` independent from `TyInfer` Add a `TyErr` type to represent unknown types in places where parse errors have happened, while still able to build the AST. Initially only used to represent incorrectly written fn arguments and avoid "expected X parameters, found Y" errors when called with the appropriate amount of parameters. We cannot use `TyInfer` for this as `_` is not allowed as a valid argument type. Example output: ```rust error: expected one of `:` or `@`, found `,` --> file.rs:12:9 | 12 | fn bar(x, y: usize) {} | ^ error[E0061]: this function takes 2 parameters but 3 parameters were supplied --> file.rs:19:9 | 12 | fn bar(x, y) {} | --------------- defined here ... 19 | bar(1, 2, 3); | ^^^^^^^ expected 2 parameters ``` Fix #34264.
☀️ Test successful - status-appveyor, status-travis |
Add a
TyErr
type to represent unknown types in places whereparse errors have happened, while still able to build the AST.
Initially only used to represent incorrectly written fn arguments and
avoid "expected X parameters, found Y" errors when called with the
appropriate amount of parameters. We cannot use
TyInfer
for this as_
is not allowed as a valid argument type.Example output:
Fix #34264.